import 'package:flutter/material.dart';

class PlayerBar extends StatefulWidget {
  const PlayerBar({super.key});

  @override
  State<PlayerBar> createState() => _PlayerBarState();
}

class _PlayerBarState extends State<PlayerBar> {
  bool _isPlaying = false;
  double _progress = 0.3;
  double _volume = 0.8;

  final String _currentSong = '大城小爱';
  final String _currentArtist = '王力宏';

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 60,
      color: const Color(0xFF2D2D2D),
      child: Row(
        children: [
          const SizedBox(width: 16),
          // 封面和歌曲信息
          Container(
            width: 48,
            height: 48,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(6),
              color: Colors.grey.shade600,
            ),
            child: const Icon(Icons.music_note, color: Colors.white, size: 24),
          ),
          const SizedBox(width: 12),
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                _currentSong,
                style: const TextStyle(
                  color: Colors.white,
                  fontSize: 14,
                  fontWeight: FontWeight.w500,
                ),
              ),
              Text(
                _currentArtist,
                style: const TextStyle(
                  color: Colors.white70,
                  fontSize: 12,
                ),
              ),
            ],
          ),
          const SizedBox(width: 20),
          // 播放控制按钮
          Row(
            children: [
              IconButton(
                icon: const Icon(Icons.skip_previous, color: Colors.white),
                onPressed: () {},
                iconSize: 24,
              ),
              Container(
                decoration: const BoxDecoration(
                  color: Colors.red,
                  shape: BoxShape.circle,
                ),
                child: IconButton(
                  icon: Icon(
                    _isPlaying ? Icons.pause : Icons.play_arrow,
                    color: Colors.white,
                  ),
                  onPressed: () {
                    setState(() {
                      _isPlaying = !_isPlaying;
                    });
                  },
                  iconSize: 20,
                ),
              ),
              IconButton(
                icon: const Icon(Icons.skip_next, color: Colors.white),
                onPressed: () {},
                iconSize: 24,
              ),
            ],
          ),
          const SizedBox(width: 20),
          // 进度条
          Expanded(
            child: Container(
              height: 40,
              padding: const EdgeInsets.symmetric(horizontal: 16),
              child: Stack(
                children: [
                  Positioned(
                    top: 8,
                    left: 0,
                    right: 0,
                    child: SliderTheme(
                      data: SliderTheme.of(context).copyWith(
                        trackHeight: 2,
                        thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 4),
                        overlayShape: SliderComponentShape.noOverlay,
                      ),
                      child: Slider(
                        value: _progress,
                        onChanged: (value) {
                          setState(() {
                            _progress = value;
                          });
                        },
                        activeColor: Colors.red,
                        inactiveColor: Colors.white30,
                      ),
                    ),
                  ),
                  const Positioned(
                    bottom: 8,
                    left: 0,
                    child: Text(
                      '01:07',
                      style: TextStyle(color: Colors.white70, fontSize: 9),
                    ),
                  ),
                  const Positioned(
                    bottom: 8,
                    right: 0,
                    child: Text(
                      '03:44',
                      style: TextStyle(color: Colors.white70, fontSize: 9),
                    ),
                  ),
                ],
              ),
            ),
          ),
          const SizedBox(width: 20),
          // 右侧控制
          Row(
            children: [
              IconButton(
                icon: const Icon(Icons.queue_music, color: Colors.white70),
                onPressed: () {},
                iconSize: 18,
              ),
              IconButton(
                icon: const Icon(Icons.lyrics, color: Colors.white70),
                onPressed: () {},
                iconSize: 18,
              ),
              IconButton(
                icon: const Icon(Icons.queue, color: Colors.white70),
                onPressed: () {},
                iconSize: 18,
              ),
              const SizedBox(width: 8),
              const Icon(Icons.volume_down, color: Colors.white70, size: 16),
              SizedBox(
                width: 80,
                child: SliderTheme(
                  data: SliderTheme.of(context).copyWith(
                    trackHeight: 2,
                    thumbShape: const RoundSliderThumbShape(enabledThumbRadius: 6),
                  ),
                  child: Slider(
                    value: _volume,
                    onChanged: (value) {
                      setState(() {
                        _volume = value;
                      });
                    },
                    activeColor: Colors.red,
                    inactiveColor: Colors.white30,
                  ),
                ),
              ),
            ],
          ),
          const SizedBox(width: 16),
        ],
      ),
    );
  }
}